<template>
    <div class="express-assign">
        <!--任务-->
        <div class="main-task" v-if="myValue['target']">
            <el-row class="paddbottm" v-show = "myValue['target']['type'] == 'go_point'">
                <el-col :span="24" class="paddbottm" style="padding-left: 20px;padding-right: 20px;">
                    <map-init
                            :poiPicker="true"
                            :isinitmap="isinitmap"
                            :inputId="inputId"
                            :lng="myValue['target']['lon']"
                            :lat="myValue['target']['lat']"
                            mapHeight="400px"
                            scale="14"
                            @positionPickerOk="mapOk"></map-init>
                </el-col>
                <el-col :span="24">
                    <el-col :span="4" class="alignright">地址：</el-col>
                    <el-col :span="18">
                        <el-col :span="24">
                            <el-input type="textarea" :rows="1" autosize  v-model="myValue['target']['address']"></el-input>
                        </el-col>
                        <el-col :span="24" style="line-height: 20px;color: red;">
                            手动修改地址后
                        </el-col>

                    </el-col>
                </el-col>
            </el-row>
            <el-row class="paddbottm" v-show="myValue['target']['type'] == 'go_spot_send'">
                <el-col :span="4" class="alignright">站点：</el-col>
                <el-col :span="8">
                    <site-select v-model="myValue['target']['spot_id']" :option="option" :palace-name="'选择站点'" style="width: 100%;"></site-select>
                </el-col>
                <el-col :span="2" class="alignright">接驳人：</el-col>
                <el-col :span="8">
                    <driver-cascader-jie v-model="myValue['target']['driver_id']" :cascaderOption="cascaderOption"  :palace-name="'默认为站长'"></driver-cascader-jie>
                </el-col>
            </el-row>
            <!--<el-row class="paddbottm" v-show="myValue['target']['type'] !== 'go_null'">-->
                <!--<el-col :span="4" class="alignright">时间：</el-col>-->
                <!--<el-col :span="18">-->
                    <!--<el-date-picker-->
                            <!--v-model="myValue['limit_time']"-->
                            <!--type="datetime"-->
                            <!--value-format="yyyy-MM-dd HH:mm:ss"-->
                            <!--style="width: 100%;"-->
                            <!--placeholder="选择日期时间">-->
                    <!--</el-date-picker>-->
                <!--</el-col>-->
                <!--<el-col :span="2" class="alignright">优先级：</el-col>-->
                <!--<el-col :span="8">-->
                    <!--<el-input type="number" v-model="myValue['priority']"></el-input>-->
                <!--</el-col>-->
            <!--</el-row>-->
            <!--<el-row class="paddbottm">-->
                <!--<el-col :span="4" class="alignright">备注：</el-col>-->
                <!--<el-col :span="18">-->
                    <!--<el-input type="textarea" v-model="myValue['comment']"></el-input>-->
                <!--</el-col>-->
            <!--</el-row>-->
        </div>
        <!--任务-->

    </div>
</template>

<script>

    // import SelectAddress from '../../map/selectAddressMap/selectAddress';
    import MapInit from '../../map/map-init';
    import MapInitNext from '../../map/map-init';
    import DriverCascaderJie from '../cascader/Cascader';
    import SiteSelect from '../cascader/Select';

    export default {
        name: "ExpressAssign",
        components: {
            // SelectAddress,
            SiteSelect,
            DriverCascaderJie,
            MapInit,
            MapInitNext
        },
        props: {
            expressModel: {
                type: String | Number,
                default: '0'
            },
            taskIndex: {  // 主任务 后置任务
                type: String | Number,
                default: '1'
            },
            mapId: {
                type: String,
                default: 'map'
            },
            inputId: {
                type: String,
                default: 'map-input'
            },
            value: {
                type: Object,
                default: () => {
                    return {}
                }
            },
            option: {
                type: Array,
                default: () => {
                    return []
                }
            },
            cascaderOption: {
                type: Array,
                default: () => {
                    return []
                }
            }
        },
        data() {
            return {
                isinitmap: true,
                siteApi: 'express/spot', // 站点api
                driverApi: 'user/driver/tree', // 司机api
                myValue: {}

            }
        },
        mounted() {
            this.myValue = this.value;
        },
        watch: {
            value: {
                handler() {
                    this.myValue = this.value;
                },
                deep:true
            },
            myValue: {
                handler(value) {
                    this.$emit('input', value);
                },
                deep: true
            }
        },
        methods: {
            mapOk(value) {
                this.myValue['target']['address'] = value.nearestJunction ? value.address + '(' + value.nearestJunction + ')' : value.address;
                this.myValue['target']['lon'] = value.position.lng;
                this.myValue['target']['lat'] = value.position.lat;
            }

        }
    }
</script>

<style scoped lang="less">
    .express-assign {
        .alignright {
            text-align: right;
        }
        .paddbottm {
            padding-bottom: 10px;
            line-height: 40px;
        }
        .dialog-footer {
            text-align: center;
        }
    }
</style>
